import React from 'react'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { Form, Upload, Button, Card, message } from 'antd'
import { UploadOutlined } from '@ant-design/icons'

export default () => {

    const handleUploadChange = (info: any): any => {
        let fileList = info.fileList;
        fileList = fileList.slice(-1);
        if (info.file.status === 'done') {
            message.success(`${info.file.name}文件上传成功`);
            fileList[0].url = fileList[0]['response']['data']['filePath'];
        }
        return fileList
    };
    return (
        <PageHeaderWrapper title={false}>
            <Card>
                <Form
                    labelCol={{ span: 3 }}
                    wrapperCol={{ span: 11 }}
                    initialValues={{ platform_enable: true, tenant_enable: true }}
                >
                    <Form.Item label="默认店铺图片" valuePropName="fileList" getValueFromEvent={handleUploadChange}>
                        <Upload
                            action='http://127.0.0.1:8888/admin/tool/upload'
                            listType='picture'
                        >
                            <Button>
                                <UploadOutlined /> Upload
                        </Button>
                        </Upload>
                    </Form.Item>
                    <Form.Item label="默认商品图片" valuePropName="fileList" getValueFromEvent={handleUploadChange}>
                        <Upload
                            action='http://127.0.0.1:8888/admin/tool/upload'
                            listType='picture'
                        >
                            <Button>
                                <UploadOutlined /> Upload
                        </Button>
                        </Upload>
                    </Form.Item>
                    <Form.Item label="默认会员头像" valuePropName="fileList" getValueFromEvent={handleUploadChange}>
                        <Upload
                            action='http://127.0.0.1:8888/admin/tool/upload'
                            listType='picture'
                        >
                            <Button>
                                <UploadOutlined /> Upload
                        </Button>
                        </Upload>
                    </Form.Item>
                    <Form.Item wrapperCol={{ offset: 3 }}>
                        <Button type="primary">保存</Button>
                    </Form.Item>
                </Form>
            </Card>
        </PageHeaderWrapper>
    )
}